package com.example.bootclockin.mapper;

import com.example.bootclockin.pojo.Todos;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@ResponseBody
public interface TodosMapper {

    @Select("select * from todos where date = #{date}")
    List<Todos> showbydate(@Param("date")String date);

    @Insert("insert todos(date,title,time,done) " +
            "values(#{date},'起床',#{time},'1');insert todos(date,title,done) " +
            "values(#{date},'数学','0'),(#{date},'英语','0')," +
            "(#{date},'运动','0'),(#{date},'睡觉','0')")
    int getupinsert(@Param("date")String date,@Param("time")String time);

    @Update("update todos set time = #{time},done = '1' " +
            "where date = #{date} and title = #{title}")
    int clockin(@Param("date")String date,@Param("title")String title,@Param("time")String time);

}
